package com.iworkh.spring.data.jdbc.tx.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;

import javax.sql.DataSource;

/**
 * transaction config
 *
 * @author: iworkh-沐雨云楼
 * @date: 2019-12-20
 */
@Configuration
public class TransactionConfig {

    @Autowired(required = false)
    private DataSource dataSource;

    @Bean("transactionManager")
    public DataSourceTransactionManager getTransactionManger(){
       return new DataSourceTransactionManager(dataSource);
    }

}
